new Vue({
    el:'#login',
    data:{
        loginName:'',
        password:''
    },
    methods:{
        login()
        {
            axios.post('/api/doLogin',
                {
                    loginName:this.loginName,
                    password:this.password
                }
                ).then(rs=>{
                    console.log(rs)
                    if(rs.data.msg==="no")
                    {
                        this.$refs.loginName.innerHTML="用户不存在"
                        this.$refs.loginName.style.color="red"
                        this.$refs.loginName.style.fontSize="12px"
                    }
                    if(rs.data.msg==="inCorrect")
                    {
                        this.$refs.userPwd.innerHTML="密码错误"
                        this.$refs.userPwd.style.color="red"
                        this.$refs.userPwd.style.fontSize="12px"
                    }
                    if(rs.data.isExist==="correct"){
                        //将令牌存入会话存储
                        window.sessionStorage.setItem("loginName",this.loginName)
                        window.sessionStorage.setItem("token",rs.data.token)
                        window.location="/api/Index.html"
                    }
            })
        }
    }
})